/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package edu.uts.reekie.designer.edit;

import java.util.List;

import org.eclipse.swt.accessibility.AccessibleEvent;

import org.eclipse.gef.AccessibleEditPart;
import org.eclipse.gef.EditPolicy;

import edu.uts.reekie.designer.conceptual.model.ViewDiagram;
import edu.uts.reekie.designer.figures.FigureFactory;
import edu.uts.reekie.designer.model.AbstractDiagram;
import edu.uts.reekie.designer.model.ModelFactory;


/**
 * Provides support for Container EditParts.
 * 
 * TODO: update to any view
 */
public abstract class ViewContainerEditPart
	extends ViewNodeEditPart
{
	
	public ViewContainerEditPart(ModelFactory mf, FigureFactory ff){
		super(mf,ff);
	}
	
protected AccessibleEditPart createAccessible() {
	return new AccessibleGraphicalEditPart(){
		public void getName(AccessibleEvent e) {
			e.result = getViewDiagram().toString();
		}
	};
}

/**
 * Installs the desired EditPolicies for this.
 */
protected void createEditPolicies() {
	super.createEditPolicies();
	installEditPolicy(EditPolicy.CONTAINER_ROLE, new LogicContainerEditPolicy());
}

/**
 * Returns the model of this as a ViewDiagram.
 *
 * @return  ViewDiagram of this.
 */
protected AbstractDiagram getViewDiagram() {
	return (AbstractDiagram)getModel();
}

/**
 * Returns the children of this through the model.
 *
 * @return  Children of this as a List.
 */
protected List getModelChildren() {
	return getViewDiagram().getChildren();
}

}
